import public_method as public_method
import configDB as Mysql_Db
import public_method as pub
import re
import filelog
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
v4_sqlMapper=Mysql_Db.Mysql('DATABASE_2')
v5_sqlMapper=Mysql_Db.Mysql('DATABASE_1')
wxsourceId=v4_sqlMapper.get_one("select id from webconfig limit 1")

print(wxsourceId)

'''
wxDetail_imgURL='http://standard.faqrobot.net/upload/web/1476067342641247/20180411/94951523413154505.jpg'
two =wxDetail_imgURL.find("/upload/web/")+1
print(wxDetail_imgURL[two:len(wxDetail_imgURL)])
 # 字符转换方法，将参数加上标点单点符号并返回
#'{"type":1,"picUrl":"/upload/default/window1.png","buttonText":"点我咨询","textColor":"#ffffff","buttonColor":"#079ed8","style":1}',
ss="".join('{"type":1,"picUrl":"/upload/default/window1.png","buttonText":"点我咨询","textColor":"#ffffff","buttonColor":"#079ed8","style":1}')
v4_sqlMapper=Mysql_Db.Mysql('DATABASE_2')
v5_sqlMapper=Mysql_Db.Mysql('DATABASE_1')
sqls="".join('<p>您好！登录电子税务局-发票使用-发票管理-发票验旧</p><p><img src="http://58.62.207.50:8180/material/downloadFileById/12669" title="95081542600433981.png" alt="image.png" style="box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 400px;"/><img src="http://58.62.207.50:8180/material/downloadFileById/12667" title="50181542600174958.png" alt="image.png" style="box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 400px;"/></p>')
answer_content="".join('<p>您好！登录电子税务局-发票使用-发票管理-发票验旧</p><p><img src="http://58.62.207.50:8180/material/downloadFileById/12669" title="95081542600433981.png" alt="image.png" style="box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 400px;"/><img src="http://58.62.207.50:8180/material/downloadFileById/12667" title="50181542600174958.png" alt="image.png" <img src="http://58.62.207.50:8180/material/downloadFileById/12661" title="95081542600433981.png" <img src="http://58.62.207.50:8180/material/downloadFileById/12662" title="95081542600433981.png" style="box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 400px;"/></p>')
#sqls="http://fengban.faqrobot.net/material/downloadFileById/71"
#ceshi=re.sub("\D","",sqls)
#print("测试：",ceshi)
#a="/"+str(43423423)
#print("首次：",sqls.find("/material/downloadFileById/"))
#one=sqls.find("/material/downloadFileById/")
#two=sqls.find('" title')
#print("第二次:",sqls.find('" title'))
#print("截取:",sqls[one:len(sqls)])
#print(re.sub("\D",'',sqls[one:len(sqls)]))
#print("sql:",sqls[sqls.index('/'):])
#print("字符串长度:",len(sqls))
#print("出现次数：",str.count(sqls,'/material/downloadFileById/'))
#str_path = wxDetail_imgURL[one:len(wxDetail_imgURL) - 1]
nums = str.count(answer_content, '/material/downloadFileById/')
print(type(answer_content))
count=0
while nums > 0:
    count += 1
    an_one = answer_content.find("/material/downloadFileById/")
    answer_substr=answer_content[an_one:len(answer_content)]
    an_two = answer_substr.find('"')+an_one
    print(an_one,an_two)
    str_path = answer_content[an_one:an_two]
    print(str_path)
    mateId = int(re.sub("\D", '', str_path))
    new_path='/upload/web/1476067342641247/20180411/80311523413121099.jpg'
    answer_content = answer_content.replace(str_path, new_path)
    print(str_path,mateId,answer_content)
    if count==nums:
        break
'''
'''    
for answer_content in range(nums):
    print(type(answer_content))
    an_one=answer_content.find("/material/downloadFileById/")
    an_two = answer_content.find('" title')
    str_path = answer_content[an_one:an_two-1]
    print(str_path)
'''
'''
# 标准问数据
questionList=v4_sqlMapper.get_all("SELECT q.id,q.question,q.queLevel,q.add_user_id,q.add_time,q.update_user_id,q.update_time,q.webId,s.group_id,s.solution_type  "\
                                  " FROM question q LEFT JOIN solution s ON q.id = s.solution_id left join classes c on s.group_id=c.id"
                                  " WHERE s.now_status=0 AND s.del = 0 AND q.del = 0 and c.del=0 and c.id is not null;")

# 相似问数据
sim_questionList=v4_sqlMapper.get_all("SELECT q.id,q.question,q.queLevel,q.add_user_id,q.add_time,q.update_user_id,q.update_time,q.webId,s.group_id,s.solution_type  "\
                                  " FROM question q LEFT JOIN solution s ON q.solution_id = s.solution_id left join classes c on s.group_id=c.id"
                                  " WHERE q.queLevel=0 and s.now_status=0 AND s.del = 0 AND q.del = 0 and c.del=0 and c.id is not null;")
'''
